//
//  AutherEmterpriseViewModel.m
//  GLGW_Shoping
//
//  Created by yang on 2018/12/6.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "AutherEmterpriseViewModel.h"
#import "NoDataFootTableViewHeaderFooterView.h"
#import "AutherEmterpriseTableViewCell.h"
#import "AutherEmterprisePictureTableViewCell.h"
#import "AdressMarkModel.h"

@interface AutherEmterpriseViewModel ()<UITableViewDelegate,UITableViewDataSource>{
    NSArray * zeroSectionPlis;
    NSArray * oneSectionPlis;
    AdressMarkModel * ad_MarkModel;
}

@end

@implementation AutherEmterpriseViewModel

-(instancetype)initWithViewToViewModel:(UITableView *)tableView theSuperView:(UIView *)superView{
    if (self = [super initWithViewToViewModel:tableView theSuperView:superView]) {
        zeroSectionPlis = @[@"请输入企业名称",@"请输入营业执照注册号",@"请输入法定代表人姓名"];
        oneSectionPlis = @[@"请输入运营者姓名",@"请输入身份证号"];
        ad_MarkModel = [AdressMarkModel new];
        tableView.mj_footer.hidden = YES;
        tableView.mj_header.hidden = YES;
        tableView.delegate = self;
        tableView.dataSource = self;
        [tableView registerClass:[NoDataFootTableViewHeaderFooterView class] forHeaderFooterViewReuseIdentifier:@"NoDataFootTableViewHeaderFooterView"];
        [superView addSubview:tableView];
    }
    return self;
}

#pragma mark -- UITableViewDelegate,UITableViewDataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    NSInteger cellNum = 1;
    switch (section) {
        case 0:{
            cellNum = 3;
        }
            break;
        case 1:{
            cellNum = 2;
        }
            break;
            
        default:
            break;
    }
    return cellNum;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 2) {
        return kHeightProportion_In_iPhoneTriploid(440);
    }else{
        return kHeightProportion_In_iPhoneTriploid(44);
    }
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    BaseTableViewCell * cell;
    if (indexPath.section == 2) {
        AutherEmterprisePictureTableViewCell * cell_picture = [AutherEmterprisePictureTableViewCell cellWithTableView:tableView];
        cell_picture.Block_PiceAction = ^(GLGWButton * _Nonnull p_but) {
            if (p_but.tag == 131) {//提交
                [self requestData];
                return;
            }
            if (self.delegate && [self.delegate respondsToSelector:@selector(cellPicetureAction:)]) {
                [self.delegate cellPicetureAction:p_but];
            }
        };
        cell = cell_picture;
    }else{
        AutherEmterpriseTableViewCell * cell_auther = [AutherEmterpriseTableViewCell cellWithTableView:tableView];
        if (indexPath.section == 0) {
            cell_auther.placeholderStr = zeroSectionPlis[indexPath.row];
        }else{
            cell_auther.placeholderStr = oneSectionPlis[indexPath.row];
        }
        cell_auther.indexPath = indexPath;
        cell_auther.markModel = ad_MarkModel;
        [cell_auther setSepartionLineWith:lineModel_Half];
        cell = cell_auther;
    }
    return cell;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    NoDataFootTableViewHeaderFooterView * headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"NoDataFootTableViewHeaderFooterView"];
    return headerView;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return kHeightProportion_In_iPhoneTriploid(10);
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    NoDataFootTableViewHeaderFooterView * footView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"NoDataFootTableViewHeaderFooterView"];
    return footView;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    if (section == 2) {
        return kHeightProportion_In_iPhoneTriploid(10);
    }else{
        return 0.01;
    }
}

#pragma mark -- 数据请求
-(void)requestData{
    
}
@end
